
//
//  FSMessageDetailViewController.m
//  WZSOA
//
//  Created by 刘沿 on 16/8/5.
//  Copyright © 2016年 刘沿. All rights reserved.
//

#import "FSMessageDetailViewController.h"


@interface FSMessageDetailViewController ()

@property (nonatomic,strong) NSMutableArray *dataArray;

@property (weak, nonatomic) IBOutlet UILabel *NameLabel;

@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UILabel *contentLabel;


@end

@implementation FSMessageDetailViewController

-(NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }

    return _dataArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
    
}

- (void)loadData{
 
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSArray * array = @[@{@"unid":self.field},@{@"userId":userId}];
    
    [HttpTools requestWithURL:KExchother arrays:array method:@"contentMessage" success:^(id JSON) {
        
        NSArray *tempArray = JSON[@"data"];
            
        _mdoel = [FSMessageModel mj_objectWithKeyValues:tempArray.firstObject];
            
        [self setcell:_mdoel];
        [self.tableView reloadData];
        
    } failure:^(NSError *error) {
        
    }];
    

}

- (void)setcell:(FSMessageModel *)model{

    self.NameLabel.text = model.acceptphoneuser;
    
    self.phoneLabel.text = model.phone;
    
    self.timeLabel.text = model.sendtime;
    
    self.contentLabel.text = model.subject;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

CGFloat H = 44;
if (indexPath.row == 0) {
      CGFloat titleSize = [OAToolBox sizebyText:_mdoel.acceptphoneuser font:17 minsWidth:80];
      H = titleSize  + 60;

}else if (indexPath.row == 1)
    {
     CGFloat titleSize = [OAToolBox sizebyText:_mdoel.phone font:17 minsWidth:80];
     H = titleSize  + 60;
    }
        

    else if (indexPath.row == 2)
    {
     CGFloat titleSize = [OAToolBox sizebyText:_mdoel.sendtime font:17 minsWidth:80];
     H = titleSize  + 60;
    }

else if (indexPath.row == 3)
    {
     CGFloat titleSize = [OAToolBox sizebyText:_mdoel.subject font:17 minsWidth:80];
     H = titleSize  + 60;
    }

    
    if (H <  60) {
    return 60;
}
else{
 return  H;

}
  }

@end
















